package com.cxyjy.cfyuiapi.controller;

import com.cxyjy.common.util.JObjectUtil;
import com.cxyjy.common.util.JResponse;
import com.cxyjy.common.util.ResultUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

import static com.cxyjy.common.constants.CfyuiConstants.WEBSOCKET_URL_STR;
import static com.cxyjy.common.util.ResultCode.PARAMS_ERROR;

/**
 * @Author: jony
 * @Date : 2024/11/5 15:28
 * @VERSION v1.0
 */
@RestController
public class WebSocketController {
    /**
     * websocket监听，
     * @param clientId
     * @return
     * @throws IOException
     */
    @GetMapping("/websocketMessage")
    public JResponse websocketMessage(String clientId) throws IOException {
        if (JObjectUtil.isEmpty(clientId)) {
            return ResultUtil.error(PARAMS_ERROR);
        }
        String urlstr = WEBSOCKET_URL_STR + "?clientId=" + clientId;
//        new WebSocketClient(urlstr);
        return ResultUtil.justSuccess();
    }
}
